package com.xbk.seckill.order.application.model.task;

import cn.hutool.core.util.StrUtil;
import com.xbk.seckill.common.model.message.TopicMessage;
import com.xbk.seckill.order.application.model.command.SeckillOrderCommand;
import lombok.Data;

/**
 * 异步下单提交的订单任务
 *
 * @author xiexu
 * @date 2025/3/2 19:00
 */
@Data
public class SeckillOrderTask extends TopicMessage {

    // 订单任务id
    private String orderTaskId;

    // 用户id
    private Long userId;

    // 提交的订单数据
    private SeckillOrderCommand seckillOrderCommand;

    public SeckillOrderTask() {
    }

    public SeckillOrderTask(String destination, String orderTaskId, Long userId, SeckillOrderCommand seckillOrderCommand) {
        super(destination);
        this.orderTaskId = orderTaskId;
        this.userId = userId;
        this.seckillOrderCommand = seckillOrderCommand;
    }

    public boolean isEmpty() {
        return StrUtil.isEmpty(this.getDestination())
                || StrUtil.isEmpty(orderTaskId)
                || userId == null
                || seckillOrderCommand == null;
    }

}
